package org.martin.snsrs.client.services;

import java.net.URI;
import java.net.URISyntaxException;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;

public class SnsrsHttpClient {
	private HttpClient client;
	
	public SnsrsHttpClient(){
		client = new DefaultHttpClient();
	}
	
	public HttpResponse get(String url) throws Exception{
		HttpGet get = new HttpGet();
		if(!url.startsWith("http:////"))
			url = "http://" + url;
		get.setURI(new URI(url));
		return client.execute(get);
	}
	
	public HttpResponse post(String url) throws Exception{
		HttpPost post = new HttpPost();
		if(!url.startsWith("http:////"))
			url = "http://" + url;
		post.setURI(new URI(url));
		return client.execute(post);
	}
}
